<template>
  <el-row :gutter="40" class="panel-group">
    <el-col :xs="18" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('userLogin')">
        <div class="card-panel-icon-wrapper icon-people">
          <svg-icon icon-class="peoples" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            访客
          </div>
          <div class="card-panel-num">{{userLoginData}}</div>
        </div>
      </div>
    </el-col>
    <el-col :xs="18" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('chatMessage')">
        <div class="card-panel-icon-wrapper icon-message">
          <svg-icon icon-class="message" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            会话消息
          </div>
          <div class="card-panel-num">{{chatMessageData}}</div>
        </div>
      </div>
    </el-col>
    <el-col :xs="18" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('chatCase')">
        <div class="card-panel-icon-wrapper icon-example">
          <svg-icon icon-class="example" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            案例
          </div>
          <div class="card-panel-num">{{chatCaseData}}</div>
        </div>
      </div>
    </el-col>
    <el-col :xs="18" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('chatRequire')">
        <div class="card-panel-icon-wrapper icon-require">
          <svg-icon icon-class="redis" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            商机
          </div>
          <div class="card-panel-num">{{chatRequireData}}</div>
        </div>
      </div>
    </el-col>
    <el-col :xs="18" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('chatRequirePlan')">
        <div class="card-panel-icon-wrapper icon-plan">
          <svg-icon icon-class="form" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            意向合作
          </div>
          <div class="card-panel-num">{{chatRequirePlanData}}</div>
        </div>
      </div>
    </el-col>
    <el-col :xs="18" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('chatRequireSummary')">
        <div class="card-panel-icon-wrapper icon-summary">
          <svg-icon icon-class="clipboard" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            合作方案
          </div>
          <div class="card-panel-num">{{chatRequireSummaryData}}</div>
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
    import CountTo from 'vue-count-to'
    import {getTotalStatistics} from "@/api/index";

    export default {
        components: {
            CountTo
        },
        data() {
            return {
                userLoginData: 0,
                chatMessageData: 0,
                chatCaseData: 0,
                chatRequireData: 0,
                chatRequirePlanData: 0,
                chatRequireSummaryData: 0,

            };
        },
        created() {
            this.totalStatistics();
        },
        methods: {
            totalStatistics() {
                getTotalStatistics().then(res => {
                    this.userLoginData = res.data.userLoginData;
                    this.chatMessageData = res.data.chatMessageData;
                    this.chatCaseData = res.data.chatCaseData;
                    this.chatRequireData = res.data.chatRequireData;
                    this.chatRequirePlanData = res.data.chatRequirePlanData;
                    this.chatRequireSummaryData = res.data.chatRequireSummaryData;
                });
            },
            handleSetLineChartData(type) {
                this.$emit('handleSetLineChartData', type)
            }
        }
    }
</script>

<style lang="scss" scoped>
  .panel-group {
    margin-top: 18px;

    .card-panel-col {
      margin-bottom: 32px;
    }

    .card-panel {
      height: 108px;
      cursor: pointer;
      font-size: 12px;
      position: relative;
      overflow: hidden;
      color: #666;
      background: #fff;
      box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
      border-color: rgba(0, 0, 0, .05);

      &:hover {
        .card-panel-icon-wrapper {
          color: #fff;
        }

        .icon-people {
          background: #6fa2be;
        }

        .icon-message {
          background: #36a3f7;
        }

        .icon-example {
          background: #f48937;
        }

        .icon-require {
          background: #cd93ea;
        }

        .icon-plan {
          background: #34bfa3;
        }

        .icon-summary {
          background: #006ebf;
        }
      }

      .icon-people {
        color: #6fa2be;
      }

      .icon-message {
        color: #36a3f7;
      }

      .icon-example {
        color: #f48937;
      }

      .icon-require {
        color: #cd93ea;
      }

      .icon-plan {
        color: #34bfa3;
      }

      .icon-summary {
        color: #006ebf;
      }

      .card-panel-icon-wrapper {
        float: left;
        margin: 14px 0 0 14px;
        padding: 16px;
        transition: all 0.38s ease-out;
        border-radius: 6px;
      }

      .card-panel-icon {
        float: left;
        font-size: 48px;
      }

      .card-panel-description {
        float: right;
        font-weight: bold;
        margin: 26px;
        margin-left: 0px;

        .card-panel-text {
          line-height: 18px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 16px;
          margin-bottom: 12px;
        }

        .card-panel-num {
          font-size: 20px;
        }
      }
    }
  }

  @media (max-width: 550px) {
    .card-panel-description {
      display: none;
    }

    .card-panel-icon-wrapper {
      float: none !important;
      width: 100%;
      height: 100%;
      margin: 0 !important;

      .svg-icon {
        display: block;
        margin: 14px auto !important;
        float: none !important;
      }
    }
  }
</style>
